package com.buobao.spring;

import com.buobao.spring.dao.EmployeeDao;
import com.buobao.spring.dao.UserDao;
import com.buobao.spring.service.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
@ComponentScan(basePackages = "com.buobao") //也可以同时支持注解扫描，这里配置注解扫描路径
public class Config {
    @Bean
    @Scope("prototype")
    public UserDao userDao(){
        UserDao userDao = new UserDao();
        return userDao;
    }

    @Bean
    public UserService userService(UserDao userDao, EmployeeDao employeeDao){
        UserService userService = new UserService();
        userService.setUserDao(userDao);
        userService.setEmployeeDao(employeeDao);
        return userService;
    }
}
